<template>
	<form @submit="submit" :data-action="`/api/runRecords/save?stationId=${param.id}&realType=${param.realType}`">
		
		<view class="plr10 ptb5 grayBg grey">
			类型
		</view>
		
		<checkbox-group @change="onChange">
			
			<label class="flex ptb10 plr10 bb"  v-for="( item , index) in options" :key="index">
				
				<text>{{item}}</text>
				
				<view class="ptb4">
					<checkbox :value="item" />
				</view>
				
			</label>
			
		</checkbox-group>
		
		<view class="plr10 ptb5 grayBg grey">
			时间
		</view>
		
		
		<view class="fixAuto bb middle">
			<view>
				<range-time-pickers startText="开始时间" endText="结束时间" @change="changeDate"></range-time-pickers>
			</view>
		</view>
		
		<view class="plr10 ptb5 grayBg flex grey">
			运维照片
		</view>
		
		<upload-img max="20" v-model="pics"></upload-img>
		
		<input type="text" name="type|请选择类型" :value="types" style="display: none;">
		<input type="text" name="startTime|请选择开始时间" :value="startDate" style="display: none;">
		<input type="text" name="endTime|请选择结束时间" :value="endDate" style="display: none;">
		<input type="text" name="pics|运维照片" :value="picsString" style="display: none;">
		
		<view style="height: 200rpx;"></view>
		<view class="plr fixed bottom ptb10 whiteBg">
			<view class="safeBottom">
				<button form-type="submit" class="btn block rds23">
					保存记录
				</button>
			</view>
		</view>
		
	</form>
	
</template>

<script>
	export default {
		data() {
			return {
				param:{id:"",realType:1} ,
				type : "" ,
				startDate : "" ,
				endDate : "" ,
				pics : [] ,
				types : ''
			}
		},
		
		computed:{
			picsString(){
				return JSON.stringify(this.pics);
			},
			options(){
				if (this.param.realType == 1) {
					return ['维护','质控','校准','故障维修']
				}
				return ['停产','停运'] ;
			}
		},
		
		onLoad(param) {
			this.param = param ;
		},
		
		methods: {
			
			submit(e){
				this.form.submit(e,this.success) ;
			},
			
			changeDate(e){
				this.startDate = e.startDate ;
				this.endDate = e.endDate ;
				console.log("this.startDate: ",this.startDate);
				console.log("this.endDate: ",this.endDate);
			},
			
			onChange(e){
				this.types = e.detail.value.join("、");
			},
			
			success:function(e){
				this.kit.goSuccessBack("保存成功");
			}
		}
	}
</script>

<style>
page{
	background-color: #fff;
}
.fixAuto{
	padding: 30upx 10upx;
}
</style>
